﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.ServiceProcess;
using System.Text;
using System.Xml;
using WebHost;

namespace windowsService
{
    public partial class Service : ServiceBase
    {
        public Service()
        {
            InitializeComponent();

        }

        protected override void OnStart(string[] args)
        {
            HostManager host = new HostManager();
            host.Start(out string errMsg);
            if (string.IsNullOrWhiteSpace(errMsg))
                Console.WriteLine("服务已启动");
            else
                Console.WriteLine(errMsg);
        }

        protected override void OnStop()
        {
            //Process proc = new Process();
            //string targetDir = System.AppDomain.CurrentDomain.BaseDirectory; ;

            //proc.StartInfo.WorkingDirectory = targetDir;
            //proc.StartInfo.FileName = "stop.bat";
            //proc.StartInfo.Arguments = string.Format("10");

            //proc.Start();
            //proc.WaitForExit();
        }
    }
}
